package com.yq.testmodule.recycleview

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager2
import androidx.recyclerview.widget.RecyclerView
import base.BaseActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.yq.testmodule.R

import config.TEST_LAYOUT_MANAGE
import java.lang.Exception


@Route(path = TEST_LAYOUT_MANAGE)
class TestRecycleViewActivity : BaseActivity() {
    override fun initLayout(): Int {
        return R.layout.activity_test_rv
    }

    lateinit var mRv: RecyclerView
    override fun initView() {
        mRv = findViewById(R.id.rv)
        val datas = arrayListOf<String>()
//        mRv.layoutManager = LinearLayoutManager(baseContext)
//        mRv.layoutManager = CustomLayoutManager()
//        mRv.layoutManager = VerticalCardLayoutManager()
//        mRv.layoutManager = LinearLayoutManager(baseContext)
        mRv.layoutManager = LinearLayoutManager2(baseContext)
        val mAdapter = CommonAdapter(datas)
        mRv.adapter = mAdapter
        for (i in 0..15) {
            val words = (Math.random() * 400).toInt()
            var content = "item$i"
            for (i in 0..words) {
                content = content + " $i"
            }
            datas.add(content)
        }
        mAdapter.notifyDataSetChanged()

    }


    override fun initData() {

    }

    private fun setMaxFlingVelocity(){
        try {
            val field = mRv.javaClass.getDeclaredField("mMaxFlingVelocity")
            field.isAccessible = true
            field.set(mRv,20000)

        }catch (e:Exception){

        }
    }
}